//
//  OPGoodLessonRoomCell.m
//  OpenPractice
//
//  Created by red on 2021/11/10.
//  Copyright © 2021 tanyuehong. All rights reserved.
//

#import "OPHomeContentCell.h"

@interface OPHomeContentCell ()

@property (nonatomic,strong) NSDictionary *data;

@property (nonatomic,strong) UILabel *titleLable;
@property (nonatomic,strong) UILabel *descLable;
@property (nonatomic,strong) UIImageView *iconImage;
@property (nonatomic,strong) UIImageView *teacherHeader;
@property (nonatomic,strong) UILabel *nameLable;
@property (nonatomic,strong) UILabel *nameTagLable;
@property (nonatomic,strong) UIImageView *userTagImage;
@property (nonatomic,strong) UIView *spreatView;

@end

@implementation OPHomeContentCell

- (instancetype)initWithContentData:(NSDictionary *)data {
    self = [super init];
    if (self) {
        self.data = data;
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 10.0;
        
        [self addSubview:self.iconImage];
        [self addSubview:self.titleLable];
        [self addSubview:self.descLable];
        [self addSubview:self.teacherHeader];
        [self addSubview:self.nameLable];
        [self addSubview:self.nameTagLable];
        [self addSubview:self.spreatView];
        //[self addSubview:self.userTagImage];
        [self layoutMySubview];
        self.iconImage.image = [UIImage imageNamed:@"ios_jichu"];
        self.teacherHeader.image = [UIImage imageNamed:@"home_user_header"];
        self.titleLable.text = @"iOS开发工程师基础入门";
        self.descLable.text = @"本课程系统的讲解了成为iOS开发必须所掌握的基本技能，面向基础。快来这里走出你iOS开发者的第一步吧";
        self.nameLable.text = @"谭月红";
        self.nameTagLable.text = @"官方讲师";
    }
    return self;
}

- (void)layoutMySubview {
    [self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.top.equalTo(@15);
        make.width.equalTo(@110);
        make.height.equalTo(@90);
    }];
    [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImage.mas_right).offset(8);
        make.top.equalTo(self.iconImage);
        make.right.equalTo(self).offset(-3);
        make.height.equalTo(@25);
    }];
    
    [self.descLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImage.mas_right).offset(8);
        make.top.equalTo(self.titleLable.mas_bottom).offset(3);
        make.right.equalTo(self).offset(-10);
        make.height.equalTo(@30);
    }];
    [self.teacherHeader mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImage.mas_right).offset(8);
        make.top.equalTo(self.descLable.mas_bottom).offset(5);
        make.width.equalTo(@25);
        make.height.equalTo(@25);
    }];
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.teacherHeader.mas_right).offset(3);
        make.top.equalTo(self.teacherHeader).offset(2);
        make.width.equalTo(@(40));
        make.height.equalTo(@20);
    }];
    
    [self.nameTagLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLable.mas_right).offset(3);
        make.top.equalTo(self.teacherHeader).offset(2);
        make.width.equalTo(@68);
        make.height.equalTo(@20);
    }];
    
    [self.spreatView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImage);
        make.right.equalTo(self.descLable);
        make.top.equalTo(self.mas_bottom).offset(-1);
        make.height.equalTo(@1);
    }];
}

- (void)updateContentData:(NSArray *)clsData {
    
}


- (UILabel *)titleLable {
    if (!_titleLable) {
        _titleLable = [[UILabel alloc] init];
        _titleLable.numberOfLines = 0;
        _titleLable.lineBreakMode = NSLineBreakByCharWrapping;
        _titleLable.textAlignment = NSTextAlignmentLeft;
        _titleLable.font = [UIFont boldSystemFontOfSize:16];
        _titleLable.textColor = kTYH333333TextColor;
    }
    return _titleLable;
}

- (UILabel *)descLable {
    if (!_descLable) {
        _descLable = [[UILabel alloc] init];
        _descLable.numberOfLines = 0;
        _descLable.lineBreakMode = NSLineBreakByTruncatingTail;
        _descLable.textAlignment = NSTextAlignmentLeft;
        _descLable.font = [UIFont systemFontOfSize:12];
        _descLable.textColor = kTYH666666TextColor;
    }
    return _descLable;
}

- (UILabel *)nameLable {
    if (!_nameLable) {
        _nameLable = [[UILabel alloc] init];
        _nameLable.lineBreakMode = NSLineBreakByTruncatingTail;
        _nameLable.textAlignment = NSTextAlignmentLeft;
        _nameLable.font = [UIFont systemFontOfSize:13];
        _nameLable.textColor = kTYH666666TextColor;
    }
    return _nameLable;
}

- (UILabel *)nameTagLable {
    if (!_nameTagLable) {
        _nameTagLable = [[UILabel alloc] init];
        _nameTagLable.textAlignment = NSTextAlignmentCenter;
        _nameTagLable.font = [UIFont systemFontOfSize:10];
        _nameTagLable.textColor = [UIColor redColor];
        _nameTagLable.layer.borderColor = [UIColor redColor].CGColor;
        _nameTagLable.layer.borderWidth = 1.0;
        _nameTagLable.layer.masksToBounds = YES;
        _nameTagLable.layer.cornerRadius = 5;
    }
    return _nameTagLable;
}

- (UIImageView *)iconImage {
    if (!_iconImage) {
        _iconImage = [[UIImageView alloc] init];
        _iconImage.layer.masksToBounds = YES;
        _iconImage.layer.cornerRadius = 5.0f;
    }
    return _iconImage;
}

- (UIImageView *)teacherHeader {
    if (!_teacherHeader) {
        _teacherHeader = [[UIImageView alloc] init];
        _teacherHeader.layer.masksToBounds = YES;
        _teacherHeader.layer.cornerRadius = 12.5f;
    }
    return _teacherHeader;
}

- (UIImageView *)userTagImage {
    if (!_userTagImage) {
        _userTagImage = [[UIImageView alloc] init];
        _userTagImage.layer.masksToBounds = YES;
    }
    return _userTagImage;
}

- (UIView *)spreatView {
    if (!_spreatView) {
        _spreatView = [[UIView alloc] init];
        _spreatView.backgroundColor = kOPSeparateBackgroundColor;
    }
    return _spreatView;
}

@end
